<?php
session_start();
class Welcome extends Controller {

	function Intro()
		{
			parent::Controller();	
		}
	
	function index()
		{
			$this->loadSettings();
			$datas	= $this->common->authenticate();
			global $userId,$now;								//оголошення $userId і $now як глобальна змінна
			$data	= array();
			if(count($datas)>0)
				{
					$data				= $datas;

					redirect("user/profile/".$this->session->userdata('user_id')."");
				}
			else
				{
					$datas	= $this->common->basicvars();
					$data	= $datas;
					$data['countAllUsr'] = $this->common->countAllUsr();
				}
				
			$this->smartyextended->view('welcome', $data);
		}
	
	function loadSettings()
		{
			global $userId,$now,$adminName,$adminEmail,$siteName,$siteTitle;
			$this->load->model('common');
			
			$userId		= $this->session->userdata('user_id');
			$now		= $this->config->item('now');
			
			$siteVars	= $this->common->getSiteVars();
			$adminName	= $siteVars['adminName'];
			$adminEmail	= $siteVars['adminEmail'];
			$siteName	= $siteVars['siteName'];
			$siteTitle	= $siteVars['siteTitle'];
		}
}
?>